﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="ArbolGen.aspx.cs" Inherits="IU.Contabilidad.PlanCuentas.ArbolGen" %>

<%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
<%@ Register src="../../Generico/ControlArbolLite.ascx" tagname="ControlArbolLite" tagprefix="uc1" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>Untitled Page</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
    
        <ext:ResourceManager ID="ResourceManager1" runat="server" />
        
        <ext:Store 
            ID="StoreComboMov" 
            runat="server" 
            >
            <Reader>
                <ext:ArrayReader>
                    <Fields>
                        <ext:RecordField Name="id" Type="Int"/>
                        <ext:RecordField Name="descrip" Type="String"/>
                    </Fields>
                </ext:ArrayReader>
            </Reader>          
        </ext:Store>   
        
        <ext:Viewport ID="Viewport1" runat="server" Layout="border">
            <Items>
                <%-- Árbol de selección de cuentas --%>
                <ext:Panel runat="server" ID="panelArbol"
                        Collapsible="false" 
                        Layout="Fit" 
                        Region="West" 
                        Collapsed="false"
                        Width="200"
                        Height="400"
                        Split="true">
                        <Content>
                            <uc1:ControlArbolLite ID="ControlArbol1" runat="server" />
                        </Content>
                </ext:Panel>
                
                <%-- Detalles de cuentas --%>
                <ext:Panel runat="server" Layout="Fit" Region="Center" ID="Center">
                <TopBar>
                    <ext:Toolbar ID="Toolbar1" runat="server">
                        <Items>
                            <ext:Button 
                                ID="ButtonAgregar"
                                Icon="NoteAdd"
                                Text="Agregar"
                                runat="server">
                                <DirectEvents>
                                    <Click OnEvent="ButtonAgregar_Click"></Click>
                                </DirectEvents>
                            </ext:Button>
                            <ext:Button 
                                ID="ButtonModificar"
                                Icon="NoteEdit"
                                Text="Modificar"
                                Hidden="true"
                                runat="server">
                                <DirectEvents>
                                    <Click OnEvent="ButtonModificar_Click"></Click>
                                </DirectEvents>
                            </ext:Button>
                            <ext:MenuSeparator runat="server"></ext:MenuSeparator>
                            <ext:Button 
                                ID="ButtonRefresh"
                                Icon="Reload"
                                Text="Actualizar"
                                runat="server">
                                <DirectEvents>
                                    <Click OnEvent="ButtonUpdate_Click">
                                        <EventMask Msg="Actualizando..." MinDelay="500" ShowMask="true" />
                                    </Click>
                                </DirectEvents>
                            </ext:Button>
                        </Items>
                    </ext:Toolbar>
                </TopBar>
                <Items>
                    <ext:FormPanel ID="FormPanelDetalles" 
                        runat="server" 
                        Border="false"
                        Height="400"
                        Width="600"
                        Title="Datos de la cuenta" 
                        Hidden="true"
                        MonitorResize="true">
                        <Items>
                            <ext:TextField ID="TextFieldCod" 
                                runat="server" 
                                AnchorHorizontal="100%" 
                                FieldLabel="Código" 
                                ReadOnly="true"
                                />
                            <ext:TextField ID="TextFieldNom" 
                                runat="server"
                                AnchorHorizontal="100%" 
                                FieldLabel="Nombre" 
                                ReadOnly="true"
                                />
                            <ext:TextField ID="TextFieldImputable" 
                                runat="server"
                                AnchorHorizontal="100%" 
                                FieldLabel="Imputable" 
                                ReadOnly="true"
                                />
                            <ext:TextField ID="TextFieldColumnaImp" 
                                runat="server"
                                AnchorHorizontal="100%" 
                                FieldLabel="Columna de impresión" 
                                ReadOnly="true"
                                />
                            <ext:TextField ID="TextFieldUnidad" 
                                runat="server"
                                AnchorHorizontal="100%" 
                                FieldLabel="Unidad"
                                Hidden="true" 
                                ReadOnly="true"
                                />
                        </Items>
                        
                    </ext:FormPanel>
                </Items>
                </ext:Panel>
                
                
                
                <%-- Ventana de eliminación --%>
                <ext:Window 
                    ID="WindowDelete" 
                    runat="server" 
                    Title="Eliminar cuenta"  
                    Icon="Delete"
                    Height="185" 
                    Width="350"
                    Closable="false"
                    Hidden="true"
                    BodyStyle="background-color: #fff;"
                    Modal="true">
                    <Items>
                        <ext:Label ID="LabelEstado" runat="server" />
                    </Items>
                    <Buttons>
                        <ext:Button ID="ButtonAceptar" Icon="Accept" 
                            Text="Si"
                            runat="server">
                            <DirectEvents>
                                <Click OnEvent="ButtonAceptar_Click" After="WindowDelete.hide();">
                                    <EventMask ShowMask="true" MinDelay="500" Msg="Eliminando..." />
                                </Click>
                            </DirectEvents>
                        </ext:Button>
                        <ext:Button ID="ButtonCancelar" Icon="Cancel" 
                            Text="No"
                            runat="server">
                            <Listeners>
                                <Click Handler="WindowDelete.hide();" >
                                </Click>
                            </Listeners>
                        </ext:Button>
                    </Buttons>
                </ext:Window>
                
            </Items>
         </ext:Viewport>
         
         <%-- Ventana de alta/modificación --%>
        <ext:Window 
            ID="VentanaAM" 
            runat="server" 
            Title="Cuenta"  
            Icon="Note"
            AutoHeight="true" 
            Width="350px"
            BodyStyle="background-color: #fff;" 
            Padding="5"
            Closable="false"
            Collapsible="false" 
            Hidden="false"
            Modal="true">
            <Items>
                <ext:FormPanel ID="FormPanelCuenta" 
                    runat="server" 
                    Border="false" 
                    Header="false" 
                    LabelAlign="Left">
                    <Defaults>
                        <ext:Parameter Name="Editable" Value="true" />
                        <ext:Parameter Name="MsgTarget" Value="side" />
                    </Defaults>
                    <Items>
                        <ext:NumberField
                            ID="FormNumberFieldCod"
                            AllowDecimals="false"
                            MinValue="1"
                            runat="server"
                            FieldLabel="Código"
                            AnchorHorizontal="90%">
                            <Listeners>
                                <Change Handler="var value = #{FormNumberFieldCod}.getValue(); if(value>9999) { #{FTextFieldImputable}.setValue('Si'); } else {#{FTextFieldImputable}.setValue('No');}" />
                            </Listeners>
                        </ext:NumberField>
                    
                        <ext:TextField 
                            ID="FormTextFieldDescripcion" 
                            runat="server" 
                            FieldLabel="Descripción" 
                            AnchorHorizontal="90%">
                        </ext:TextField>
                                
                        <ext:TextField 
                            ID="FormTextFieldCapi" 
                            runat="server" 
                            FieldLabel="Capítulo" 
                            AnchorHorizontal="90%">
                        </ext:TextField>
                                                                  
                        <ext:NumberField
                            ID="FormNumberFieldColumn"
                            AllowDecimals="false"
                            MinValue="1"
                            MaxLength="1"
                            FieldLabel="Columna de impresión"
                            AnchorHorizontal="90%"
                            runat="server">
                        </ext:NumberField>
                        
                        <ext:ComboBox
                            ID="ComboBoxHabilitada"
                            FieldLabel="Habilitada"
                            AnchorHorizontal="90%"
                            runat="server">
                            <Items>
                                <ext:ListItem Text="No" Value="0" />
                                <ext:ListItem Text="Sí" Value="1" />
                            </Items>
                            <SelectedItem Value="1" />
                        </ext:ComboBox>
                        
                        <ext:TextField 
                            runat="server" 
                            ID="FTextFieldImputable" 
                            ReadOnly="true" 
                            FieldLabel="Imputable" 
                            AnchorHorizontal="90%">
                        </ext:TextField>
                        
                        <%--<ext:ComboBox
                            ID="ComboBoxImputable"
                            FieldLabel="Imputable"
                            Editable="false"
                            Selectable="false"
                            AnchorHorizontal="90%"
                            runat="server">
                            <Items>
                                <ext:ListItem Text="No" Value="0" />
                                <ext:ListItem Text="Sí" Value="1" />
                            </Items>
                            <SelectedItem Value="1" />
                        </ext:ComboBox>--%>
                    </Items>
                </ext:FormPanel>
            </Items>
            <Buttons>
                <ext:Button ID="FormBotonAceptar"
                    Text="Aceptar"
                    Icon="Accept"
                    runat="server">
                    <DirectEvents>
                        <Click OnEvent="Form_BotonAceptar_Click" After="VentanaAM.hide();">
                            <ExtraParams>
                                <ext:Parameter 
                                    Name="values" 
                                    Value="#{FormPanelCuenta}.getForm().getValues()" 
                                    Mode="Raw" Encode="true" />
                            </ExtraParams>
                            <EventMask ShowMask="true" MinDelay="500" />
                        </Click>
                    </DirectEvents>
                </ext:Button>
                <ext:Button ID="FormBotonCancelar" 
                    Text="Cancelar"
                    Icon="Cancel"
                    runat="server">
                    <DirectEvents>
                        <Click OnEvent="Form_BotonCancelar_Click" Before="#{FormPanelCuenta}.getForm().reset();"  After="VentanaAM.hide();"></Click>
                    </DirectEvents>
                </ext:Button>
            </Buttons>
        </ext:Window>
    </div>
    </form>
</body>
</html>
